<?php

require_once ('models/BaseModel.class.php');
class ProvinceModel extends BaseModel {
	/**
	 *
	 * @var Logger
	 */
	private $_logger;
	public function __construct() {
		parent::__construct ();
		Logger::configure ( ROOT_PATH . 'config/log_config.xml' );
		$this->_logger = Logger::getLogger ( __CLASS__ );
	}
	
	/**
	 * <h2>查询出所有的省份</h2>
	 * <p>每个省份是一个CMAP结构，有两个属性id, name
	 * </p>
	 *
	 * @return CLIST(CMAP(id,name))
	 */
	public function getAll() {
		$list = new CLIST ();
		$query = 'SELECT id, name FROM provinces';
		$conn = DBHelper::getDB ( false );
		
		$resultSet = $conn->select ( $query );
		for($i = 0; $i < count ( $resultSet ); ++ $i) {
			$map = new CMAP ( $resultSet [$i] );
			$list->append ( $map );
		}
		return $list;
	}
}